/**
 * 将时间戳转换为日期字符串（year-month-day hours:minutes:seconds）
 * @param 时间戳
 * @returns 日期字符串
 */
const timestampToDateString = (timestamp: number | string): string => {
    timestamp = Number(timestamp);
    // 创建一个 Date 对象
    const date = new Date(timestamp);

    // 格式化日期和时间
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份是 0-11，所以要加 1
    const day = String(date.getDate()).padStart(2, "0");
    const hours = String(date.getHours()).padStart(2, "0");
    const minutes = String(date.getMinutes()).padStart(2, "0");
    const seconds = String(date.getSeconds()).padStart(2, "0");

    // 返回格式化后的日期时间字符串
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};

export default timestampToDateString;